/*
 * @Descripttion: 医生创建一个处方
 * @version: 1.0
 * @Author: 自由如风
 * @Date: 2021-04-28 19:21:04
 * @LastEditors: 自由如风
 * @LastEditTime: 2021-04-28 20:56:30
 */

const DB = require("../../lib/DB");
const { Success } = require("../../lib/Response");

module.exports = async function (ctx, next) {
    const { prescription_number, patient, diagnose_sort_id, diagnose_result, transfusion, flesh, change_drug, cure, get_drug, memo, diagnose_date, doctor, cure_fee} = ctx.request.body;
    try {
        const prescription = await DB.models.prescription.create({ prescription_number, patient, diagnose_sort_id, diagnose_result, transfusion, flesh, change_drug, cure, get_drug, memo, diagnose_date, doctor, cure_fee });
        ctx.body = new Success(prescription.toJSON())
    } catch (e) {
        console.error(e)
        throw new Error("创建失败")
    }
}